﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Windows.Forms.DataVisualization.Charting;

namespace IAD2
{
    class MyChart : Chart
    {

        public MyChart()
        {
            this.Size = new Size(600, 250);

            var chartArea = new ChartArea();

            chartArea.AxisX.MajorGrid.LineColor = Color.LightGray;
            chartArea.AxisY.MajorGrid.LineColor = Color.LightGray;
            chartArea.AxisX.LabelStyle.Font = new Font("Consolas", 8);
            chartArea.AxisY.LabelStyle.Font = new Font("Consolas", 8);
            this.ChartAreas.Add(chartArea);
        }


        public void AddSeries(List<Neuron> points)
        {
           
            List<double> xvals = new List<double>();
            List<double> yvals = new List<double>();
            foreach (Neuron p in points)
            {
                xvals.Add((double)p.X);
                yvals.Add((double)p.Y);
            }

            var series = new Series();

            series.Name = "Punkty " + this.Series.Count;
            series.ChartType = SeriesChartType.FastPoint;
            series.XValueType = ChartValueType.Double;
            this.Series.Add(series);

            // bind the datapoints
            this.Series[series.Name].Points.DataBindXY(xvals, yvals);

        }

        public void Save(String name)
        {
            // draw!
            //this.ChartAreas[0].AxisY.Maximum = 5;
            // this.ChartAreas[0].AxisY.Minimum = 0;
            this.Legends.Add(new Legend("Default") { Docking = Docking.Right });
            this.Invalidate();

            // write out a file
            this.SaveImage(name + ".png", ChartImageFormat.Png);
        }


    }
}
